<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    姓名:<input type="text" class="username" /><button>下一步</button>
    <script>
      let usernaemEle = document.querySelector(".username");
      if (sessionStorage.getItem("username")) {
        usernaemEle.value = sessionStorage.getItem("username");
      }

      document.querySelector("button").onclick = function () {
        let val = usernaemEle.value;
        sessionStorage.setItem("username", val);
        window.location.href = "register2.html";
      };
    </script>
  </body>
</html>
